package com.data.modules.system.service.impl;


import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.data.modules.smzh.mapper.FacedeviceMapper;
import com.data.modules.system.entity.Account;
import com.data.modules.system.entity.SysUser;
import com.data.modules.system.mapper.AccountMapper;
import com.data.modules.system.service.IAccountService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @Description: 测试
 * @Author: data-boot
 * @Date:   2022-11-08
 * @Version: V1.0
 */
@Service
public class AccountServiceImpl extends ServiceImpl<AccountMapper, Account> implements IAccountService {


    @Autowired
    private FacedeviceMapper facedeviceMapper;

    @Override
    public Account getUserByNameForExt(String accountMobile){
        LambdaQueryWrapper<Account> query = new LambdaQueryWrapper<>();
        query.eq(Account::getAccountMobile,accountMobile);
        Account result = this.baseMapper.selectOne(query);

        return result;
    }

    @Override
    public void saveAccountInfo(SysUser user) {

        Account account = new Account();
        account.setAccountMobile(user.getUsername());
        account.setAccountPassword(user.getPassword());
        account.setAccountEmail(user.getUsername()+"@sm-ioe.com");
        this.save(account);
        Long id = account.getId();
        facedeviceMapper.saveDevelappInfo(user.getUsername(),id);

    }
}
